<?php global $has_permit; ?>
    <form action="<?php echo site_url('admin/medical/department/index', true); ?>" method="post" id="frm_department_search">
    <?php if ($has_permit) :?>
    <div class="std_header auto_height">
        <div class="left">
            <strong><?php echo $module['title']; ?></strong>
        </div>
        <div class="right">
            <?php if ($has_privilege_new) :?>
            <button type="button" class="gray_btn" onclick="window.location='<?php echo site_url('admin/medical/department/edit', true); ?>'"><span>Thêm mới</span></button>
            <?php endif; ?>
        </div>
    </div>
    <div id="department_management">
        <?php if (count($collection) != 0) : ?>
        <?php $paginator = $this->load->view('medical/department/paginator', null, true); echo $paginator; ?>
        <?php endif; ?>
        <input type="hidden" name="current_page" id="current_page" value="<?php echo $current_page; ?>" />

        <?php $this->load->view('medical/department/message'); ?>
            <div class="block">
                <table class="gridview" width="100%" cellpadding="0" cellspacing="0" border="0">
                    <thead>
                    <tr>
                        <td><input id="check_all" type="checkbox" onclick="btn_util.check_all(this.checked, '.chk_id')" /></td>
                        <td><b>ID</b></td>
                        <td><b>Tên bộ phận</b></td>
                        <td><b>Ảnh minh họa</b></td>
                        <td><b>Mô tả ngắn</b></td>
                        <td><b>Hiển thị</b></td>
                        <td><b>Thao tác</b></td>
                    </tr>
                    </thead>
                    <tbody>
                        <tr class="filters">
                            <td colspan="2"><input placeholder="ID" type="text" class="small_filter" name="filters[id]" title="Tìm kiếm theo id bộ phận cơ thể" value="<?php echo isset($filters['id']) ? $filters['id'] : '' ;?>" /></td>
                            <td><input placeholder="Tên" style="width: 150px;" type="text" class="small_filter" name="filters[name]" title="Tìm kiếm theo tên bộ phận cơ thể" value="<?php echo isset($filters['name']) ? $filters['name'] : '' ; ?>" /></td>
                            <td></td>

                            <td colspan="3">
                                <select name="filters[is_hidden]">
                                    <option value="0">Hiển thị</option>
                                    <option value="1" <?php if(isset($filters['is_hidden']) && $filters['is_hidden'] == 1):?> selected="selected" <?php endif ;?>>Hiện</option>
                                    <option value="2" <?php if(isset($filters['is_hidden']) && $filters['is_hidden'] == 2):?> selected="selected" <?php endif ;?>>Ẩn</option>
                                </select>
                                <button type="button" class="gray_btn" style="margin-left:10px;position:relative;top:2px" onclick="return admin_medical_department.act_filter()">
                                    <span>Tìm</span>
                                </button>
                                &nbsp;
                                <button type="button" class="gray_btn" style="position:relative;top:2px" onclick="return admin_medical_department.reset_filters('frm_department_search')">
                                    <span>Xóa lọc</span>
                                </button>
                            </td>
                        </tr>
                        <?php if (count($collection) != 0) : ?>
                        <?php foreach ($collection as $department) : ?>
                            <tr>
                                <input type="hidden" value="" class="edit_url" />
                                <td width="30px" valign="top">
                                    <input class="chk_id" type="checkbox" name="selected[]" value="<?php echo $department->id; ?>" />
                                </td>
                                <td width="30px" valign="top">
                                    <?php echo $department->id; ?>
                                </td>
                                <td valign="top">
                                    <strong><a <?php if ($has_privilege_view) :?>href="<?php echo site_url('admin/medical/department/edit/id/' . $department->id, true); ?>"<?php endif; ?>><?php echo $department->name; ?></a></strong>
                                </td>
                                <td width="100px" valign="top">
                                    <?php if (!empty($department->image)) :?>
                                    <a target="_blank" href="<?php echo render_src($department->image); ?>"><img src="<?php echo render_src($department->image); ?>" width="50px" style="vertical-align: middle; border: 2px solid #bbb" /></a>
                                    <?php endif; ?>

                                </td>
                                <td width="260px" valign="top">
                                    <?php echo $department->description; ?>
                                </td>

                                <td valign="top" width="80px">
                                    <?php if ($department->is_hidden == 1) :?>
                                    <strong>Hiện</strong>
                                    <?php else :?>
                                    <strong style="color: red;">Ẩn</strong>
                                    <?php endif; ?>
                                </td>

                                <td valign="top" width="80px">
                                    <p>
                                        <?php if ($has_privilege_view) :?>
                                        <a class="icon icon_edit" href="<?php echo site_url('admin/medical/department/edit/id/' . $department->id, true); ?>"></a>
                                        <?php endif; ?>
                                        <?php if ($has_privilege_delete) :?>
                                        <a class="icon icon_delete" href="<?php echo site_url('admin/medical/department/delete/id/' . $department->id, true); ?>" onclick="return confirm('Bạn muốn xóa khoa này?')"></a>
                                        <?php endif; ?>
                                    </p>
                                </td>
                            </tr>
                        <?php endforeach; ?>

                        <?php else : ?>
                            <tr>
                                <td colspan="9" style="padding: 10px">
                                    <p align="center">Danh sách khoa trống trong thời điểm này hoặc truy vấn tìm kiếm không tìm thấy kết quả, <a href="<?php echo site_url('admin/medical/department/filtered_list/' . $return_url, true); ?>">Thử lại</a></p>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                    <tfoot>

                    </tfoot>
                </table>
            </div>


        <?php if (count($collection) != 0) : ?>
        <?php $paginator = $this->load->view('medical/department/paginator', null, true); echo $paginator; ?>
        <?php endif; ?>

    </form>
    </div>
    <?php else :?>
        <?php $this->load->view('layouts/restricted'); ?>
    <?php endif; ?>

<div class="clearfix"></div>
<script type="text/javascript">

</script>
<script type="text/javascript" src="<?php echo BASE_URL; ?>js/admin/medical/object/function.js"></script>